;;;Create Pline in Mspace matching current Vport boundary and hatch inside.
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe Street
;;;		Southern Pines, NC 28387
;;;
;;;	http://paracadd.com
;;;	All rights reserved.
;;;
;;;	Copyright: 1991-2004
;;;
(defun c:kbnd ()
  (if c:mklayr nil (load"mklayr"))
  (c:svlayr)
  (setq curvno (getvar"cvport"))
  (setq cvputw (-(* pi 2)(getvar"viewtwist")))
;;;  (regapp "ACAD")
  (setq cvpss (ssget "X" (LIST (CONS 410 (GETVAR "CTAB"))(CONS 69 curvno))))
  (setq cvpent (entget (ssname cvpss 0)(list "ACAD")))
  (setq cvpvno (atoi(substr(cdr(assoc 8 cvpent))5 2)))
  (setq cvphgt (getvar"viewsize"))
  (setq cvpctr (getvar"viewctr"))
  (setq cvpa40 (cdr(assoc 40 cvpent)))
  (setq cvpa41 (cdr(assoc 41 cvpent)))
  (setq cvpwid (*(/ cvpa40 cvpa41)cvphgt))
;  (setq xvdata (cadr(assoc -3 cvpent)))
  (setq pt1 (polar(polar cvpctr cvputw (/ cvpwid 2))
                  (- cvputw(/ pi 2))
                  (/ cvphgt 2)
            )
        pt2 (polar pt1 (+ cvputw(/ pi 2)) cvphgt)
        pt3 (polar pt2 (+ cvputw pi) cvpwid)
        pt4 (polar pt3 (- cvputw(/ pi 2)) cvphgt)
  )
  (setq ltyp "-"
        prod "VI03"
        colr "4"
        colri nil
        colra nil
        modf (strcat "V" (itoa cvpvno) "KM")
  )
  (c:mklayr)
  (setq oldss (ssget "x" (list(cons 8 (strcat "*" modf)))))
  (if oldss
    (command "._erase" oldss "")
  )
  (command "._pline" pt1 pt2 pt3 pt4 "c")
  (setq colr "1"
        colri nil
        colra nil
  )
  (c:mklayr)
  (command "._hatch" "ansi31" 500 0 (entlast) "")
  (c:rslayr)
  (IF (SSGET "X" '((8 . "*VI031*")))
    (COMMAND "-LAYER" "C" "1" "*VI031*" "")
  )
  (IF (SSGET "X" '((8 . "*VI034*")))
    (COMMAND "-LAYER" "C" "4" "*VI034*" "")
  )
  (IF vpset NIL (LOAD "vpset" "\nFile VPSET.LSP not loaded! "))
  (vpset cvpvno)
  (if c:isovp nil (load "isovp"))
  (c:isovp)
)